/* test : method calls, variable range, ... */

object Fibo{
   def main() : Unit = {
      println((new Fibonacci()).run(42));
   }
}

class Fibonacci{

   var x : Int;
   var y : Int;

   def run(nStep : Int) : Int ={
      x = 0;
      y = 1;

      while(0 < nStep){
	 println(this.get());
	 if(!(this.step() == 1))
	    nStep = nStep - 50;

	 nStep = nStep -1;
      }
      return nStep;
   }

   def init(): Int ={
      x = 0;
      y = 1;
      return 1;
   }

   def step() : Int ={
      var temp : Int;
      temp = x+y;
      x = y;
      y = temp;
      return 1;
   }

   def get() : Int = {
      var x : Int; // create local variable
      x = y;
      return x;
   }
}
